package com.sctvcloud.dongqu.ui.receiver;

import android.app.Notification;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;

import com.sctvcloud.dongqu.R;
import com.sctvcloud.dongqu.base.BaseActivity;

/**
 * Created by Administrator on 2017/7/19 0019.
 */

public class SubscribeReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        String id = intent.getStringExtra(BaseActivity.EX_ID);
        String url = intent.getStringExtra(BaseActivity.EX_URL);
        String title = intent.getStringExtra(BaseActivity.EX_TITLE);
//        Intent detailIntent = new Intent(context, LivingActivity.class);
//        detailIntent.putExtra(BaseActivity.EX_URL, url);
//       // detailIntent.putExtra(BaseActivity.EX_TITLE, title);
//        PendingIntent pendingIntent = PendingIntent.getActivity(context, Integer.parseInt(id),
//                detailIntent, 0);
        String notStr = "您预约的《" + title + "》直播快要开始了，请前往四川观察app观看";
        NotificationCompat.Builder notification = new NotificationCompat.Builder(context)
                .setSmallIcon(R.mipmap.ic_launcher)
                .setContentTitle(context.getResources().getString(R.string.app_name))
                // .setContentIntent(pi)
                .setAutoCancel(true)
                .setDefaults(Notification.DEFAULT_ALL)
                .setContentText(notStr);
        NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(Integer.parseInt(id), notification.build());
    }
}
